#include "SiteParser.h"

#include <QDebug>
#include <QCoreApplication>
#include <QIODevice>
#include <QRegExp>
#include "siteParsers/SiteParser.h"
#include "siteParsers/hotfileparser.h"
#include "siteParsers/filesonic.h"
#include "siteParsers/wupload.h"

SiteParser::SiteParser(){
    buf=new QString();
}

SiteParser* SiteParser::getInstance(QString server){
    //qDebug()<<"server::"<<server;
    if(server==HotFileParser::site){
            SiteParser* parser=new HotFileParser();
            return parser;
    } else if(FileSonic::site.contains(server)){
            SiteParser* parser=new FileSonic();
            return parser;
    } else if(server==WUpload::site){
            SiteParser* parser=new WUpload();
            return parser;
    }else{
        qDebug()<<"Unknown page "<<server;
        //emit skipFile();
        return NULL;
    }
}

void SiteParser::testPage(){
//    qDebug()<<*buf;
    if(buf->length()<10)return;
    parsePage(*buf);

    delete this->buf;
    this->buf=new QString();
   };

void SiteParser::append(QString text){
    buf->append(text);
}

int SiteParser::getShortDelay(){
    return 62; // default over 1 minute
}

SiteParser::~SiteParser(){
    delete buf;
}


